package main

import (
	"context"
	"core/coreinit"
	"core/corerun"
	"core/corestruct"
	"core/db"
	"core/server/baseserver"
	"core/server/httpserver"
	"fmt"
	"ht/htinit"
	"ht/htrun"
	"ht/service/htfile"
)

func main() {
	coreinit.Init()
	htinit.Init()

	var svr = &htfile.HtfileService{}
	var mold, _ = svr.Get(297773005281566720)
	var b = svr.SavePdfShow(mold)
	fmt.Println(b)

	var ctx = &corestruct.HttpContext{
		Id: 0,
		Session: &corestruct.HttpSession{
			CrtUid:   1000,
			HtdeptId: 1000,
		},
		DB: db.DbMaster,
	}

	dbctx := context.WithValue(context.Background(), "MyContext", ctx)
	var db = db.DbMaster.WithContext(dbctx)
	ctx.DB = db

	corerun.DbSetup("core")
	corerun.StructToDb("core", db)

	corerun.DbSetup("ht")
	corerun.StructToDb("ht", db)

	htrun.DbSetup(ctx)
	corerun.ActionToDb("ht", db)
	htrun.HtMeueSetup(ctx)
	//fmt.Println("aaa")
	httpserver.Run()

	baseserver.WaitCloseSignals()
}
